import Cookie from 'js-cookie'
import {COOKIE_LIST} from '@/util/constant'

export const doAuth = function () {
  const token = Cookie.get(COOKIE_LIST.AUTHORIZATION)
  return token && token.length > 0
}

export const setUpCookie = function () {
  Object.assign(Cookie.defaults, { expires: 7 })
}

export const setCookie = function (key, value) {
  Cookie.set(key, value)
}

export const removeCookie = function (key) {
  Cookie.remove(key)
}

export const clearCookie = function () {
  Object.keys(COOKIE_LIST).forEach((key) => {
    removeCookie(key)
  })
}

export const doAuthFail = function () {
}
